<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>我的预约实验室-添加</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="STATIC/css/font.css">
    <link rel="stylesheet" href="STATIC/css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="STATIC/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="STATIC/js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
<div class="x-body">
    <form class="layui-form">
        <div class="layui-form-item">
            <label for="L_username" class="layui-form-label">
                <span class="x-red">*</span>当前实验室
            </label>
            <div class="layui-input-inline">

                <input class="layui-input" value='{switch name="tea_lab->getLab($tea_lab->lab_id)->week"}
                {case value="1"}周一{/case}
                {case value="2"}周二{/case}
                {case value="3"}周三{/case}
                {case value="4"}周四{/case}
                {case value="5"}周五{/case}
                {case value="6"}周六{/case}
                {case value="7"}周日{/case}
                {/switch}---{switch name="tea_lab->getLab($tea_lab->lab_id)->node"}
                    {case value="1"}1,2节{/case}
                    {case value="2"}3,4节{/case}
                    {case value="3"}5,6节{/case}
                    {case value="4"}7,8节{/case}
                    {case value="5"}9,10节{/case}
                    {/switch}---{$tea_lab->getLab($tea_lab->lab_id)->address}' disabled>

            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_username" class="layui-form-label">
                课程名称
            </label>
            <div class="layui-input-inline">
                <input disabled type="text" value="{$tea_lab->name}" id="name" name="name"
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <i title="修改名称" onclick="edit_name()" class="layui-icon">&#xe642;</i>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_username" class="layui-form-label">
                容纳量
            </label>
            <div class="layui-input-inline">
                <input disabled type="text" value="{$tea_lab->max_number}" id="max_number" name="max_number"
                       class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <i title="修改人数" onclick="edit_max_number()" class="layui-icon">&#xe642;</i>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_username" class="layui-form-label">
                <span class="x-red">*</span>周几
            </label>
            <div class="layui-input-inline">
                <select name="week" id="week" class="valid">
                    <option selected value="">不限</option>
                    {volist name="week_labs" id="week_lab"}
                        {switch name="week_lab"}
                            {case value="1"}
                            <option value="{$week_lab}">周一</option>
                            {/case}
                            {case value="2"}
                            <option value="{$week_lab}">周二</option>
                            {/case}
                            {case value="3"}
                            <option value="{$week_lab}">周三</option>
                            {/case}
                            {case value="4"}
                            <option value="{$week_lab}">周四</option>
                            {/case}
                            {case value="5"}
                            <option value="{$week_lab}">周五</option>
                            {/case}
                            {case value="6"}
                            <option value="{$week_lab}">周六</option>
                            {/case}
                            {case value="7"}
                            <option value="{$week_lab}">周日</option>
                            {/case}
                        {/switch}
                    {/volist}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_username" class="layui-form-label">
                <span class="x-red">*</span>节数
            </label>
            <div class="layui-input-inline">
                <select name="node" id="node" class="valid">
                    <option selected value="">不限</option>
                    {volist name="node_labs" id="node_lab"}
                        {switch name="node_lab"}
                            {case value="1"}
                                <option value="1">1,2节</option>
                            {/case}
                            {case value="2"}
                                <option value="2">3,4节</option>
                            {/case}
                            {case value="3"}
                                <option value="3">5,6节</option>
                            {/case}
                            {case value="4"}
                                <option value="4">7,8节</option>
                            {/case}
                            {case value="5"}
                                <option value="5">9,10节</option>
                            {/case}
                        {/switch}
                    {/volist}
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label for="L_repass" class="layui-form-label">
            </label>
            <a onclick="select_lab()" class="layui-btn">
                查询实验室
            </a>
            <a class="layui-btn" onclick="save_lab()" type="submit">
                确认修改
            </a>
        </div>
    </form>
    <div  class="layui-form-item">
        <label  for="L_username" class="layui-form-label">
            <span class="x-red">*</span>可选实验室
        </label>
        <div   class="layui-input-inline">
            <select id="lab" name="lab">

            </select>
        </div>
    </div>

</div>

</body>

<script>
    function edit_name() {
        layer.msg('可以修改课程名了',{icon: 6,time:1000});

        $('#name').attr("disabled", false);
    }

    function edit_max_number() {
        layer.msg('可以修改容纳人数了',{icon: 6,time:1000});
        $('#max_number').attr("disabled", false);
    }
    function select_lab() {
        var nade=document.getElementById("node").value;
        var week=document.getElementById("week").value;
        $.get("/index/admin/GetAjax_select_lab",{ "week": week,'node':nade,'id':{$tea_lab->id}},function(data){
            if (data!=-1){
                data=eval(data);
                var str_op='';
                for(var i in data){
                    str_op+="<option value='"+data[i]['id']+"'>"+data[i]['address']+"</option>"
                }
                $("#lab").html(str_op);
                layer.msg(data[0],{icon: 6,time:1000});

            }else{
                layer.msg('没有可选的实验室!',{icon:2,time:3000});
            }
        });
    }
    function save_lab() {
        var name=document.getElementById("name").value;
        var max_number=document.getElementById("max_number").value;
        var new_labid=document.getElementById("lab").value;
        layer.confirm('如果不需要修改实验室请点[取消]？',function(){
        $.get("/index/admin/my_tea_lab_c",{'new_labid':new_labid,'id':{$tea_lab->id},'labid':{$tea_lab->lab_id},'max_number':max_number,'name':name},function(data){
            if (data==1){

                layer.msg('修改成功!',{icon: 6,time:1000});

            }else{
                layer.msg('没有可选的实验室!',{icon:2,time:3000});
            }
        });});
    }
</script>

</html>